import Opt from '@/components/dt/info/Opt.js'
import toolMgr from '@/biz/base/tool.js'

class Column extends Opt {
  constructor() {
    super()
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      {
        type: 'index',
        title: '序号',
        width: 60
      },
      {
        field: 'contractName',
        title: '合同名称',
        minWidth: 160
      },
      {
        field: 'contractBeginTime',
        title: '合同开始日期',
        width: 160
      },
      {
        field: 'contractEndTime',
        title: '合同结束日期',
        width: 200
      },
      {
        field: 'attachList',
        title: '合同附件',
        minWidth: 160,
        cell: (item) => {
          return {
            edit: {
              tag: {
                type: 'text',
                options: item.attachList.map((i) => ({
                  key: i.imageURL,
                  value: i.imageName
                })),
                style: {
                  display: 'block'
                },
                click: (tag) => {
                  toolMgr.downloadFile(tag.key, tag.value)
                }
              }
            }
          }
        }
      },
      {
        title: '操作',
        width: 80,
        fixed: 'right',
        cell: {
          btn: [
            {
              title: '编辑',
              event: 'onEditContract',
              code: '0102010802'
            }
          ]
        }
      }
    ]
  }
}

export default Column
